import tnx from '@/tnx.js';

/**
 * 枚举子类型显示名称
 */
export default class EnumSubTypeCaption {

    subname = '';
    caption = '';

    constructor(subname, caption) {
        this.subname = subname;
        this.caption = caption;
    }

    static of(object) {
        if (typeof object !== 'object') {
            return undefined;
        }
        let subCaption = new EnumSubTypeCaption(this.subname, this.caption);
        subCaption.update(object);
        return subCaption;
    }

    update(object) {
        return tnx.util.object.rewriteSimpleDefined(this, object);
    }

    clone() {
        return EnumSubTypeCaption.of(this);
    }

}
